package deom1;

import java.util.ArrayList;
import java.util.List;

public class Test1 {

}

class Solution1 {
    public boolean isPalindrome(String s) {
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            if (Character.isLetterOrDigit(s.charAt(i))) {   //是字母和数字
                if (Character.isLetter(s.charAt(i))) {  //是字母
                    stringBuffer.append(Character.toLowerCase(s.charAt(i)));
                } else {  //是数字
                    stringBuffer.append(s.charAt(i));
                }
            }
        }
        int lfet = 0;
        int right = stringBuffer.length() - 1;
        while (lfet < right) {
            if (stringBuffer.charAt(lfet) != stringBuffer.charAt(right)) {
                return false;
            }
            lfet++;
            right--;
        }
        return true;
    }
}

class Solution2 {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> list = new ArrayList<List<Integer>>();
        for (int i = 0; i < numRows; i++) {
            List<Integer> ret = new ArrayList<>();
            for (int j = 0; j <= i ; j++) {
                if (j == 0 || i == j) {
                    ret.add(1);
                } else {
                    ret.add(list.get(i - 1).get(j - 1) + list.get(i - 1).get(j));
                }
            }
            list.add(ret);
        }
        return list;
    }
}

class Solution3 {
    public int waysToStep(int n) {
        int a = 1;
        int b = 2;
        int c = 4;
        int d = 7;
        if (n == 1 || n == 2) {
            return n;
        }
        if (n == 3) {
            return 4;
        }
        int ret = n - 3;
        while (ret != 0) {
            a = b;
            b = c;
            c = d;
            d = a + b + c;
            ret--;
        }
        return d;
    }
}
